﻿using System;
class ArrIntSum
{
    static int InputNumberInRange()
    {
        int number = 0;
        do
        {
            if (number != 0)
            {
                Console.Write("the number is not in range 1..99999 ");
            }
            while (true)
            {
                try
                {
                    number = int.Parse(Console.ReadLine());
                    break;
                }
                catch (Exception)
                {
                    Console.Write("Please re-enter number: ");
                }
            }
        } while ((number < 0) || (number > 99999));

        return number;
    }
    static int[] NumberToArray(int number)
    {
        string numStr = number.ToString();
        string temp = "";
        int[] arr = new int[numStr.Length];
        for (int i = 0, j = (numStr.Length - 1); i < numStr.Length; i++, j--)
        {
            temp = ""+numStr[j];
            arr[i] = int.Parse(temp);
            //Console.WriteLine(arr[i]);
        }
        return arr;
    }
    static int[] ResultOfAddingArrays(int[] arrayOne, int[] arrayTwo)
    {
      //  int counter = 0;
        if (arrayOne.Length > arrayTwo.Length)
        {
            for (int i = 0; i < (arrayTwo.Length); i++)
            {
                arrayOne[i] = arrayOne[i] + arrayTwo[i];
                if (arrayOne[i] > 9)
                {
                    arrayOne[i] = arrayOne[i] % 10;
                    arrayOne[i + 1] = arrayOne[i + 1] + 1;
                  //  counter = i;
                }

            }
            for (int j = arrayTwo.Length; j < arrayOne.Length; j++)
            {
                if (arrayOne[j] > 9)
                {
                    arrayOne[j + 1] = arrayOne[j + 1] + 1;
                }
            }
        } 
        return arrayOne;
    }
    static void Main()
    {

        int firstNumber = 0;
        int secondNumber = 0;
 
        Console.Write("pleae input first number between [1...99 999]: ");
        firstNumber = InputNumberInRange();
        Console.Write("pleae input second number between [1...99999]: ");
        secondNumber = InputNumberInRange();
        Console.WriteLine("{0}, {1}",firstNumber, secondNumber);
        int[] firstNumArr = NumberToArray(firstNumber);
        int[] secondNumberArr = NumberToArray(secondNumber);
        int[] res = ResultOfAddingArrays(firstNumArr, secondNumberArr);
        for (int i = firstNumArr.Length - 1; i >= 0; i--)
        {
            Console.Write(res[i]);
        }
   //     res = ResultOfAddingArrays(firstNumArr, secondNumberArr);
        Console.ReadLine();
    }
}

